$(function(){
    obj.init();
});

var obj = new JsFun();
function JsFun(){
    'use strict';
    return {
        dataGrid: null,
        schoolId: null,
        init: function () {
            window.top.swal.resetDefaults();
            this.dataGrid = new xhDataGrid($('#list'), 'School/getChangeSchoolData?schoolId='+this.schoolId);
            this.dataGrid.parseToolbar().init();
            this.listener();
        },
        listener: function () {
            var $this = this;
            $('#bt_list_search').click(function () {
                $this.funObj().search();
            })
            xhTool.bindDocKeyDown($('#bt_list_search'));
            $("#bt_list_check").click(function () {
                $this.funObj().check()
            })
            $("#bt_list_check_final").click(function () {
                $this.funObj().checkFinal()
            })
            $("#bt_list_del").click(function () {
                $this.funObj().del()
            })
        },
        funObj: function(){
            var $this = this;
            return {
                search: function () {
                    $this.dataGrid.reload({
                        search: xhExtra.getValue($('#list_search_vague')),
                        status: xhExtra.getValue($('#list_search_status')),
                        changeStatus: xhExtra.getValue($('#list_search_change_status')),
                    });
                },
                check: function () {
                    var ids = $this.dataGrid.getSelectValues('iId');
                    if (ids.length <= 0) {
                        window.top.xhTop.showError('未选中记录！');
                        return false;
                    }
                    xhExtra.askChangeStatus('School/changeSchoolCheck', {ids: ids}, $this.dataGrid, '确定审核吗？');
                },
                checkFinal: function () {
                    var ids = $this.dataGrid.getSelectValues('iId');
                    if (ids.length <= 0) {
                        window.top.xhTop.showError('未选中记录！');
                        return false;
                    }
                    xhExtra.askChangeStatus('School/changeSchoolCheckFinal', {ids: ids}, $this.dataGrid, '确定转校吗？');
                },
                del: function () {
                    var ids = $this.dataGrid.getSelectValues('iId');
                    console.log(ids)
                    if (ids.length <= 0) {
                        window.top.xhTop.showError('未选中记录！');
                        return false;
                    }
                    xhExtra.askChangeStatus('School/delChangeSchool', {ids: ids}, $this.dataGrid);
                }
            }
        }
    }
}

